/**
 * @param {string} s
 * @return {number}
 */
var balancedString = function (s) {
 let res = 0
 function count(str){
    let map = new Map()
    for(const c of str){
      map.set(c,map.has(c)?map.get(c)+1:1)
    }
    let arr = [...map.values()]
    for(let i=0;i<arr.length;i++){
      if(arr[i]>1){
        res+=arr[i]-1
      }
    }
 }
 for(let i=0;i<s.length;i+=4){
   count(s.slice(i,i+4))
 }
return res

}


console.log(balancedString("WWQQRRRRQRQQ"));